/**
 * Created by liulingling on 17/8/17.
 */
/**
 * 校验是不是手机号
 * */
function _isPhone(str) {
    var partten = /^(0|86|17951)?(13[0-9]|15[0-9]|17[0-9]|18[0-9]|14[0-9])[0-9]{8}$/;
    if (!partten.test(str.replace(/[ ]/g, ""))) {
        return false;
    } else {
        return true;
    }
}

/**
 * 输入特殊字符判断
 * */
function _isSpecailWords(str) {
    var pattern = new RegExp("[`~!@#$%^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，？]")
    return pattern.test(str);
}

/**
 * 检验是否是邮箱
 * */
function _isMail(str) {
    var partten = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
    if (!partten.test(str)) {
        return false;
    } else {
        return true;
    }
}

/**
 * 错误图片替换
 * */
function _errorImg(dom, imgurl) {
    $(dom + ' img').attr('onerror', 'this.src="' + imgurl + '"');//未获取图片
}

/**
 * 判断是不是PC端，如果是，返回true
 * */
function IsPC() {
    var userAgentInfo = navigator.userAgent;
    var Agents = ["Android", "iPhone",
        "SymbianOS", "Windows Phone",
        "iPad", "iPod"];
    var flag = true;
    for (var v = 0; v < Agents.length; v++) {
        if (userAgentInfo.indexOf(Agents[v]) > 0) {
            flag = false;
            break;
        }
    }
    return flag;
}

/**
 * js获取地址栏的参数
 * */
function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null)return unescape(r[2]);
    return null;
}

/**
 * js获取地址栏的参数
 * */
function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null)return unescape(r[2]);
    return null;
}

$(function () {
    /**
     * 菜单高亮js
     * */
    $('.xx' + window.location.pathname.split('/')[1]).addClass('active');

    /**左侧导航折叠动画效果的实现
     * @param el
     * @param multiple
     * @constructor
     */
    var Accordion = function (el, multiple) {
        this.el = el || {};
        this.multiple = multiple || false;

        // Variables privadas
        var links = this.el.find('.link');
        // Evento
        links.on('click', {el: this.el, multiple: this.multiple}, this.dropdown)
    }

    Accordion.prototype.dropdown = function (e) {
        var $el = e.data.el;
        $this = $(this),
            $next = $this.next();

        $next.slideToggle();
        $this.parent().toggleClass('open');

        if (!e.data.multiple) {
            $el.find('.submenu').not($next).slideUp().parent().removeClass('open');
        }
        ;
    }
    var accordion = new Accordion($('#accordion'), false);
    $(".open ul").css("display", 'block')
});